<template>
  <BaseContainer>
    <aplid-base-crud ref="crud" class="w-100" v-bind="{...theConfig,...$attrs}">
      <template v-slot:ArchivesDialog="{ row, show }">
        <OrgArchives @rechange="handleOperate" @refresh="handleRefresh" :key="show" :nowRowData="row">
        </OrgArchives>
        <InsArchives @rechange="handleOperate" @refresh="handleRefresh" :key="show" :nowRowData="row">
        </InsArchives>
      </template>
    </aplid-base-crud>

    <el-dialog v-model="dialogVisible" title="数据变更" width="65%">
      <RechangeDetail v-if="dialogVisible" @refresh="handleRefresh" :batchNumber="nowData.dataStatus"></RechangeDetail>
    </el-dialog>
  </BaseContainer>
</template>

<script setup lang="ts">
import { baseConfig } from './config'
import InsArchives from '../serviceIns/index.vue'
import OrgArchives from '../serviceOrg/index.vue'
import { editConfig } from '@/views/datacenter/comprehensiveQueries/utils/index'
type Props = {
  isComprehensiveQueries?:boolean
}
let props = withDefaults(defineProps<Props>(),{
  isComprehensiveQueries:false
})
let theConfig:any = ref({})
if(baseConfig){
  let defaultConfig = JSON.parse(JSON.stringify(baseConfig))
  if(props.isComprehensiveQueries){
    theConfig.value = editConfig(defaultConfig)
  }else{
    theConfig.value = baseConfig
  }
}

const crud = ref()
let nowData: any = {}
const dialogVisible = ref(false)
const handleRefresh = () => {
  nextTick(() => {
    dialogVisible.value = false
    crud.value.refreshChange()
  })
}

const handleOperate = (type, row, title) => {
  nextTick(() => {
    crud.value.handleOperate(type, row, title)
  })
}

</script>

<style scoped></style>
